package cn.edu.xmut.chen.zhlg.zhlg.file.controller;

import cn.edu.xmut.chen.zhlg.common.HttpResult.Result;
import cn.edu.xmut.chen.zhlg.zhlg.file.entity.File;
import cn.edu.xmut.chen.zhlg.zhlg.file.service.FileService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/upload")
@CrossOrigin
@Api("文件上传 API")
public class FileController {
    @Resource
    private FileService fileService;

    @RequestMapping(method = RequestMethod.POST, value = "/avatar")
    public Result uploadAvatar(@RequestParam("file") MultipartFile file) {
        return Result.success("上传成功").data(fileService.uploadAvatar(file));
    }
}
